<template>
	<view class="page">
		<view class="infoItem" v-for="(infoItem, infoItemIndex) in myInfoList" :key="infoItem.ID" @click="gotoInfoContent(infoItem.ID)">
			<view class="infoItemLeft">
				<view class="infoItemContent">{{ infoItem.Content }}</view>
				<view class="InfoItemPhone">电话：{{ infoItem.Phone }}</view>
			</view>
			<view class="infoItemRight" @click="callPhone(infoItemIndex)">
				<image src="../../static/infoIco/phone.png" mode="aspectFit" class="infoItemRightPhone"></image>
				<view class="infoItemRightText">拨打电话</view>
			</view>
		</view>
		<!-- <view class="infoItem" v-for="i in 10" :key="i">
			<view class="infoItemLeft">
				<view class="infoItemContent">海山医药事业部：《动销师》《带教业务员》1、负责全天驻店销售。2、工作区域按家庭住址就近分配。3、薪资待...</view>
				<view class="InfoItemPhone">电话：15143596225</view>
			</view>
			<view class="infoItemRight">
				<image src="../../static/infoIco/phone.png" mode="aspectFit" class="infoItemRightPhone"></image>
				<view class="infoItemRightText">拨打电话</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		name:"NewsPaperInfoItem",
		data() {
			return {
				isCollection:false,
				myInfoList:[],
			};
		},
		props: {
			infoList: {
				type: Array,
				default() {
					return [];
				}
			}
		},
		methods:{
			// setTimeTxt(time){
			// 	return getDateDiff(parseInt(time)*1000) + ' ' +  getFormatTime(parseInt(time), 'Y-M-D h:m:s')
			// },
			showInfoItemMenu(e){
				this.myInfoList.forEach((el, index)=>{
					if(e.target.id != index){
						el = Object.assign(el,{'Menu':false})
					}
				})
				if (this.myInfoList[e.target.id].Menu === true) {
					this.myInfoList[e.target.id].Menu = false
				} else {
					this.myInfoList[e.target.id].Menu = true
				}
				this.$forceUpdate()  // 进行强制渲染,效果实现。
			},
			callPhone(index){
				uni.makePhoneCall({
				    phoneNumber: this.myInfoList[index].Phone //仅为示例
				});
			},
			gotoinfoReport(index) {
				let item = this.myInfoList[index];		 
				uni.navigateTo({
				  url: '../infoReport/infoReport?infoid=' + item.ID + "&classid=" + item.LanMuID,
				})
			 },
			 setInfoCollection(index){
				 let infoid = this.myInfoList[index].ID
				 this.$api.setInfoCollection({xxid:infoid, openid:getApp().globalData.openid})
				 .then(res =>{
					 console.log(res)
					 if (this.myInfoList[index].IsSC == 1){
						 this.myInfoList[index].IsSC = 0
					 }else{
						 this.myInfoList[index].IsSC = 1
					 }
					 this.$forceUpdate()  // 进行强制渲染,效果实现。
					 uni.showToast({
					 	title:res.msg,
						icon:'success',
					 })				 
				 })
			 },
			 infoimagePreview(index,infoindex){
				 let infoimages = []
				 this.myInfoList[infoindex].tpdata.forEach((tupianItem) =>{
					 infoimages.push(this.$getImgUrl(tupianItem.imgpath))
				 })
				 uni.previewImage({
					 current:index,
					 urls:infoimages,
				 })
			 },
			 gotoInfoContent(infoId){
				console.log(infoId)
				uni.navigateTo({
					url:'../../pages/newsPaperShow/newsPaperShow?infoId=' + infoId
				})
			 },
		
		},
		watch: {
			infoList: function(newVal, oldVal) {
				this.myInfoList = newVal;
				console.log(this.myInfoList)
			}
		}
	}
</script>

<style scoped>
@import url("NewsPaperInfoItem.css");
</style>
